package com.winchain.chainbill.bill.biz.discount.cmd;

import com.shell.bee.acct.transaction.po.AcctTxRec;
import com.shell.framework.command.CallbackContext;
import com.shell.framework.command.CommandContext;
import com.shell.framework.command.ICallback;
import com.shell.framework.command.ICommand;
import com.winchain.chainbill.bill.base.po.CbDct;
import com.winchain.chainbill.bill.base.po.CbRec;
import com.winchain.chainbill.bill.biz.Bill;
import com.winchain.chainbill.bill.biz.receive.service.BillCertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillDctCertCmd implements ICommand<Bill<CbDct>>, ICallback<Bill<CbDct>, AcctTxRec> {
	@Autowired
	private BillCertService billCertService;

	public boolean callback(CallbackContext<Bill<CbDct>, AcctTxRec> context) throws Exception {
		execute(context);
		return false;
	}

	public boolean execute(CommandContext<Bill<CbDct>> context) throws Exception {
		CbDct cbDct = (CbDct) ((Bill) context.getSource()).getSource();
		CbRec cbRecord = ((Bill) context.getSource()).getRec();
		this.billCertService.cert(cbRecord, cbDct);
		return false;
	}
}
